package org.cancer.dao

import org.cancer.util.JDBCUtil

import java.sql.Connection

class HighRiskDao {
  def insertHighRiskPatient(ts: String, installment: String, transfer: String, complications: String): Unit = {
    val conn: Connection = JDBCUtil.getConnection
    try {
      val sql = "INSERT INTO Patient_Data (ts, installment, transfer, complications) VALUES (?, ?, ?, ?)"
      JDBCUtil.executeUpdate(conn, sql, Array(ts, installment, transfer, complications))
      println("成功存入高危患者数据")
    } catch {
      case e: Exception =>
        println(s"存入数据时发生错误: ${e.getMessage}")
        e.printStackTrace()
    } finally {
      if (conn != null) conn.close()
    }
  }
}
